#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<sys/stat.h>
#include<fcntl.h>
 
int main(int argc,char* argv[]){
     if(argc!=3){
         printf("%s [file name] [copy file name]\n",argv[0]);
         exit(0);
     }
 
    char *cmd1;
     char *cmd2;
 
    cmd1 = argv[1]; //file name
     cmd2 = argv[2]; //copy file name
 
    char block[BUFSIZ];
     int in, out;
     int nread;
 
    in = open(cmd1,O_RDONLY); //원본파일
     out = open(cmd2, O_WRONLY| O_CREAT, S_IRUSR| S_IWUSR);//만들파일
     nread = read(in,block,sizeof(block)); //읽은만큼 nread가 올라가고
     write(out,block,nread);          //read만큼 쓴다.
 
    exit(0);
 }

